//
//  HYOUTopicDetailTableView.m
//  BestGift
//
//  Created by 温晓宇 on 16/1/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HYOUTopicDetailTableView.h"
#import "HYOUTopicDetailTableViewCell.h"

@interface HYOUTopicDetailTableView ()<UITableViewDataSource, UITableViewDelegate>

@end
@implementation HYOUTopicDetailTableView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews{
    self.myTableView = [[HYOUBaseTableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain];
//    self.myTableView.backgroundColor = [UIColor whiteColor];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    [self addSubview:self.myTableView];

    
    [self.myTableView registerClass:[HYOUTopicDetailTableViewCell class] forCellReuseIdentifier:@"cell"];
}
-(NSInteger)numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.bigArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HYOUTopicDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    HYOUOneCellModel *model = [self.bigArray objectAtIndex:indexPath.row];
    cell.model = model;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    HYOUOneCellModel *model = [self.bigArray objectAtIndex:indexPath.row];
    [self.delegate listTopicWeb:model.content_url Image:model.cover_image_url title:model.title];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 150;
}
-(void)setBigArray:(NSMutableArray *)bigArray{
    if (_bigArray != bigArray) {
        [_bigArray release];
        _bigArray = [bigArray retain];
    }
    [self.myTableView reloadData];
}
@end
